<?php

/**
 * This is the model class for table "kunjunganremajasehat".
 *
 * The followings are the available columns in table 'kunjunganremajasehat':
 * @property integer $krs_id
 * @property integer $krs_kec
 * @property integer $krs_laki
 * @property integer $krs_perempuan
 * @property integer $krs_jumlah
 * @property integer $krs_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $krsKec
 */
class Kunjunganremajasehat extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Kunjunganremajasehat the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'kunjunganremajasehat';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('krs_kec, krs_laki, krs_perempuan, krs_jumlah, krs_tahun', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('krs_id, krs_kec, krs_laki, krs_perempuan, krs_jumlah, krs_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'krsKec' => array(self::BELONGS_TO, 'Kecamatan', 'krs_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'krs_id' => 'Krs',
			'krs_kec' => 'Krs Kec',
			'krs_laki' => 'Krs Laki',
			'krs_perempuan' => 'Krs Perempuan',
			'krs_jumlah' => 'Krs Jumlah',
			'krs_tahun' => 'Krs Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('krs_id',$this->krs_id);
		$criteria->compare('krs_kec',$this->krs_kec);
		$criteria->compare('krs_laki',$this->krs_laki);
		$criteria->compare('krs_perempuan',$this->krs_perempuan);
		$criteria->compare('krs_jumlah',$this->krs_jumlah);
		$criteria->compare('krs_tahun',$this->krs_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}